package com.lagou.zkweb;

import org.I0Itec.zkclient.ZkClient;

public class Zk {

    private static ZkClient zkClient;

    /**
     * 连接zk，并创建path
     */
    public static ZkClient connect() {
        zkClient = new ZkClient(CommonUtil.ZK_SERVER);
        if (!zkClient.exists(CommonUtil.DB_PATH)) {
            zkClient.createPersistent(CommonUtil.DB_PATH, true);
        }
        zkClient.writeData(CommonUtil.DB_PATH, CommonUtil.config);
        return zkClient;
    }
}
